#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int upper(int a[], int n, int x)
{
	int lo = 0, hi = n - 1, mid;
	while (lo < hi)
	{
		mid = (lo + hi + 1) / 2;
		printf("UPPER: (%d, %d)-%d\n", lo, hi, mid);
		if (a[mid] <= x)
			lo = mid;
		else
			hi = mid - 1; 
	}
	return lo;
}

int lower(int a[], int n, int x)
{
	int lo = 0, hi = n - 1, mid;
	while (lo < hi)
	{
		mid = (lo + hi) / 2;
		printf("LOWER: (%d, %d)-%d\n", lo, hi, mid);
		if (a[mid] >= x)
			hi = mid;
		else
			lo = mid + 1; 
	}
	return lo;
}

int
main(int argc, char **argv)
{
	int i, len, target, *arr;
	while(scanf("%d", &len)!=EOF && len) {
		arr = (int *)malloc(len*sizeof(int));
		for(i=0; i<len; i++)
			scanf("%d", arr+i);

		while(1) {
			printf("Your Target: ");
			scanf("%d", &target);
			if(target)
				printf("Lower: %d, Upper: %d\n", lower(arr, len, target), upper(arr, len, target));
			else
				break;
		}
		free(arr);
	}
}
